home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 22
/
Cream of the Crop 22.iso
/
bbs
/
pad321.zip
/
CHAR.MH
< prev
next >
Wrap
Text File
|
1996-08-21
|
3KB
|
106 lines
// Defines various character related operations and operations between characters
// and strings. See string.mh for string-related operations.
//
// Function list:
//
// bool isDigit (char: ch);
// bool isUpper (char: ch);
// bool isLower (char: ch);
// char upChar (char: ch);
// char lowChar (char: ch);
// int hexDig (char: ch);
// int countChar (string: source, char: toCount)
// void stripChar (Ref string: source, char: toStrip)
// void appendChar (Ref string: source, char: toAppend)
// string stripCharf (string: source, char: toStrip)
// string appendCharf (string: source, char: toAppend)
//
// void charInit ();
// int charToken (string: token, string: params);
#ifndef __CHAR_MH
#define __CHAR_MH
#ifndef __GENERAL_MH
#include "general.mh"
#endif
// isDigit returns true if the given character is a digit
// between 0 and 9.
//bool isDigit (char: ch) {
// bool: temp;
// print ("got here (char.mh)\n");
// getch ();
// temp := ((ch >= '0') and (ch <= '9'));
// if ((ch >= '0') and (ch <= '9')) {
// print ("returning true\n");
// getch ();
// vidsync ();
// temp := True;
// }
// else {
// print ("returning false\n");
// getch ();
// vidsync ();
// temp := False;
// };
// print ("left isDigit ()\n");
// }
// print ("endif");
// getch ();
// return temp;}
// isLower returns true if the given character is a lower case letter.
bool isLower (char: ch) {
return ((ch >= 'a') and (ch <= 'z'));}
// isUpper returns true if the given character is an upper case letter.
bool isUpper (char: ch) {return ((ch >= 'A') and (ch <= 'Z'));}
// lowChar converts a character to its lower-case equivilant.
//char lowChar (char: ch) {
// if (isUpper (ch)) {return ch - 'A' + 'a';};
// return ch;
// }
// hexDig returns the value of a hexidecimal digit. Returns -1 if the
// character is not a valid hex digit. Valid hex digits are 0..9,
// a..f, and A..F. This function should return a value in the range
// of 0..15 if the given character is a valid hex digit.
//int hexDig (char: hex) {
// if (isDigit (hex)) return hex - '0';
// if (isUpper (hex)) return hex - 'A' + 10;
// if (isLower (hex)) return hex - 'a' + 10;
// return -1;
// }
// Appends a character to a string, modifying the original string.
void appendChar (Ref string: theString, char: theChar) {
theString [strlen(theString)+1] := theChar;
}
// AppendCharf appends a char to a string without modifying the original
// string. Returns the new string.
//string appendCharf (string: theString, char: theChar) {
// appendChar (theString, theChar);
// return theString;
// }
// stripCharf removes all occourances of a given character from a string. The
// original string is not modified - the new string is returned by the function.
//string stripCharf (string: theString, char: ch) {
// stripChar (theString, ch);
// return theString;
// }
#endif